package com.xxl.job.admin.feign;

import com.xxl.job.admin.core.model.XxlJobGroup;
import com.xxl.job.admin.core.model.XxlJobInfo;
import com.xxl.job.core.biz.model.ReturnT;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestParam;

/**
 * xxl-job 服务端rpc接口
 *
 * @Author: pc
 * @CreateDate: 2021/10/21 11:40
 */
@FeignClient(contextId = "IJobProdiver", value = "st-xxl-job-admin", url ="http://st-gateway:9999/xxl-job-admin")
public interface IJobProdiver {

	/**
	 * 获取执行器id
	 *
	 * @param appName
	 * @return
	 */
	@GetMapping("/job/getGroupIdByAppName")
	ReturnT<Integer> getGroupIdByAppName(@RequestParam("appName") String appName);

	/**
	 * 新增执行器
	 *
	 * @param xxlJobGroup
	 * @return
	 */
	@PostMapping("/job/addJobGroup")
	ReturnT<Integer> addJobGroup(@RequestBody XxlJobGroup xxlJobGroup);

	/**
	 * 获取job任务信息
	 *
	 * @param jobId
	 * @return
	 */
	@GetMapping("/job/getJobInfo")
	ReturnT<XxlJobInfo> getJobInfo(@RequestParam("jobId") int jobId);

	/**
	 * 新增job任务
	 *
	 * @param jobInfo
	 * @return
	 */
	@PostMapping("/job/addJob")
	ReturnT<String> addJob(@RequestBody XxlJobInfo jobInfo);

	/**
	 * 更新job任务
	 *
	 * @param jobInfo
	 * @return
	 */
	@PostMapping("/job/updateJob")
	ReturnT<String> updateJob(@RequestBody XxlJobInfo jobInfo);

	/**
	 * 停止job任务
	 *
	 * @param id
	 * @return
	 */
	@GetMapping("/job/pause")
	ReturnT<String> pause(@RequestParam("id") int id);

	/**
	 * 开始job任务
	 *
	 * @param id
	 * @return
	 */
	@GetMapping("/job/start")
	ReturnT<String> start(@RequestParam("id") int id);

	/**
	 * 删除job任务
	 *
	 * @param id
	 * @return
	 */
	@GetMapping("/job/remove")
	ReturnT<String> remove(@RequestParam("id") int id);

}
